function [r_, beta_, lambda_, c0_, logL_] = quickPS2_fit(data, lambda)% function [r_, beta_, lambda_, c0_, logL_] = quickPS_fit(data, lambda)%% Probability summation version of the quick fit% data is [cohs times correct] x trials%if nargin < 1 | isempty(data)  return;endglobal DATADATA = data;clear data;% if lambda is given, use it...otherwise it's a parameter to fitif nargin < 2 | isempty(lambda)  % generate guess  q_guess = [1 1 0 0];  lb      = [0.00001; 0;  0; 0];  ub      = [100000; Inf; 1; 1];else  q_guess = [1 1 lambda 0];  lb      = [0.00001; 0;  lambda; 0];  ub      = [100000; Inf; lambda; 0];end%% Use fmincon to find the fitquickF = fmincon('quickPS2_err', q_guess, [], [], [], [], lb, ub, ...					  [], optimset('LargeScale', 'off'));r_ 	    = quickF(1);beta_ 	= quickF(2);lambda_ = quickF(3);c0_ 	= quickF(4);logL_ 	= quickPS2_err(quickF);